home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Diamond Collection / The Diamond Collection (Software Vault)(Digital Impact).ISO / cdr44 / frasrc19.zip / FRACTINT.H < prev    next >
C/C++ Source or Header  |  1995-03-04  |  26KB  |  896 lines

  1. /* FRACTINT.H - common structures and values for the FRACTINT routines */
  2.  
  3. #ifndef FRACTINT_H
  4. #define FRACTINT_H
  5.  
  6. #include <math.h>
  7. #ifndef PORT_H
  8. #include "port.h"
  9. #endif
  10. #ifndef BIGNUM_DEFINED
  11. #include "bignum.h"
  12. #include "bigflt.h"
  13. #endif
  14.  
  15. typedef BYTE BOOLEAN;
  16.  
  17. #ifndef C6
  18. #define _fastcall    /* _fastcall is a Microsoft C6.00 extension */
  19. #endif
  20.  
  21. #ifndef XFRACT
  22. typedef int SEGTYPE;
  23. typedef unsigned USEGTYPE;
  24. #ifdef __TURBOC__
  25. #   define _bios_printer(a,b,c)   biosprint((a),(c),(b))
  26. #   define _bios_serialcom(a,b,c) bioscom((a),(c),(b))
  27. #else
  28. #ifndef __WATCOMC__
  29. #ifndef MK_FP
  30. #   define MK_FP(seg,off) (VOIDFARPTR )( (((long)(seg))<<16) | \
  31.                                           ((unsigned)(off)) )
  32. #endif
  33. #endif
  34. #endif
  35. #else
  36. typedef char * SEGTYPE;
  37. typedef char * USEGTYPE;
  38. #   define MK_FP(seg,off) (VOIDFARPTR )(seg+off)
  39. #include <sys/types.h> /* need size_t */
  40. #endif
  41.  
  42.  
  43. #ifndef XFRACT
  44. #define clock_ticks() clock()
  45. #endif
  46.  
  47. #ifdef XFRACT
  48. #define _fstrcpy(to,from) strcpy(to,from)
  49. #define _fmemmove(a,b,c) (bn_t)memmove(a,b,c)
  50. #define _fmemset(a,b,c) (bn_t)memset(a,b,c)
  51. #define _fmemcpy(a,b,c) (bn_t)memcpy(a,b,c)
  52. #define difftime(now,then) ((now)-(then))
  53. #endif
  54.  
  55. /* for gotos in former FRACTINT.C pieces */
  56. #define RESTART           1
  57. #define IMAGESTART        2
  58. #define RESTORESTART      3
  59. #define CONTINUE          4
  60.  
  61. /* these are used to declare arrays for file names */
  62. #define FILE_MAX_PATH  80       /* max length of path+filename  */
  63. #define FILE_MAX_DIR   80       /* max length of directory name */
  64. #define FILE_MAX_DRIVE  3       /* max length of drive letter   */
  65. #define FILE_MAX_FNAME  9       /* max length of filename       */
  66. #define FILE_MAX_EXT    5       /* max length of extension      */
  67.  
  68. #define MAX_CODES   4095        /* for decoder arrays */
  69.  
  70. #define MAXPARAMS 10        /* maximum number of parameters */
  71. #define MAXPIXELS 2048        /* Maximum pixel count across/down the screen */
  72. #define DEFAULTASPECT ((float)0.75)/* Assumed overall screen dimensions, y/x  */
  73.  
  74. struct videoinfo {        /* All we need to know about a Video Adapter */
  75.     char    name[26];    /* Adapter name (IBM EGA, etc)        */
  76.     char    comment[26];    /* Comments (UNTESTED, etc)        */
  77.     int    keynum;     /* key number used to invoked this mode */
  78.                 /* 2-10 = F2-10, 11-40 = S,C,A{F1-F10}    */
  79.     int    videomodeax;    /* begin with INT 10H, AX=(this)    */
  80.     int    videomodebx;    /*        ...and BX=(this)    */
  81.     int    videomodecx;    /*        ...and CX=(this)    */
  82.     int    videomodedx;    /*        ...and DX=(this)    */
  83.                 /* NOTE:  IF AX==BX==CX==0, SEE BELOW    */
  84.     int    dotmode;    /* video access method used by asm code */
  85.                 /*    1 == BIOS 10H, AH=12,13 (SLOW)    */
  86.                 /*    2 == access like EGA/VGA    */
  87.                 /*    3 == access like MCGA        */
  88.                 /*    4 == Tseng-like  SuperVGA*256    */
  89.                 /*    5 == P'dise-like SuperVGA*256   */
  90.                 /*    6 == Vega-like     SuperVGA*256    */
  91.                 /*    7 == "Tweaked" IBM-VGA ...*256  */
  92.                 /*    8 == "Tweaked" SuperVGA ...*256 */
  93.                 /*    9 == Targa Format        */
  94.                 /*    10 = Hercules            */
  95.                 /*    11 = "disk video" (no screen)   */
  96.                 /*    12 = 8514/A            */
  97.                 /*    13 = CGA 320x200x4, 640x200x2    */
  98.                 /*    14 = Tandy 1000         */
  99.                 /*    15 = TRIDENT  SuperVGA*256    */
  100.                 /*    16 = Chips&Tech SuperVGA*256    */
  101.     int    xdots;        /* number of dots across the screen    */
  102.     int    ydots;        /* number of dots down the screen    */
  103.     int    colors;     /* number of colors available        */
  104.     };
  105.  
  106. typedef struct videoinfo far        VIDEOINFO;
  107. #define INFO_ID     "Fractal"
  108. typedef    struct fractal_info FRACTAL_INFO;
  109.  
  110. /*
  111.  * Note: because non-MSDOS machines store structures differently, we have
  112.  * to do special processing of the fractal_info structure in loadfile.c.
  113.  * Make sure changes to the structure here get reflected there.
  114.  */
  115. #ifndef XFRACT
  116. #define FRACTAL_INFO_SIZE sizeof(FRACTAL_INFO)
  117. #else
  118. /* This value should be the MSDOS size, not the Unix size. */
  119. #define FRACTAL_INFO_SIZE 502
  120. #endif
  121.  
  122. struct fractal_info        /*  for saving data in GIF file     */
  123. {
  124.     char  info_id[8];        /* Unique identifier for info block */
  125.     short iterationsold;    /* Pre version 18.24 */
  126.     short fractal_type;        /* 0=Mandelbrot 1=Julia 2= ... */
  127.     double xmin;
  128.     double xmax;
  129.     double ymin;
  130.     double ymax;
  131.     double creal;
  132.     double cimag;
  133.     short videomodeax;
  134.     short videomodebx;
  135.     short videomodecx;
  136.     short videomodedx;
  137.     short dotmode;
  138.     short xdots;
  139.     short ydots;
  140.     short colors;
  141.     short version;        /* used to be 'future[0]' */
  142.     float parm3;
  143.     float parm4;
  144.     float potential[3];
  145.     short rseed;
  146.     short rflag;
  147.     short biomorph;
  148.     short inside;
  149.     short logmap;
  150.     float invert[3];
  151.     short decomp[2];
  152.     short symmetry;
  153.             /* version 2 stuff */
  154.     short init3d[16];
  155.     short previewfactor;
  156.     short xtrans;
  157.     short ytrans;
  158.     short red_crop_left;
  159.     short red_crop_right;
  160.     short blue_crop_left;
  161.     short blue_crop_right;
  162.     short red_bright;
  163.     short blue_bright;
  164.     short xadjust;
  165.     short eyeseparation;
  166.     short glassestype;
  167.             /* version 3 stuff, release 13 */
  168.     short outside;
  169.             /* version 4 stuff, release 14 */
  170.     double x3rd;      /* 3rd corner */
  171.     double y3rd;
  172.     char stdcalcmode;      /* 1/2/g/b */
  173.     char useinitorbit;      /* init Mandelbrot orbit flag */
  174.     short calc_status;      /* resumable, finished, etc */
  175.     long tot_extend_len;  /* total length of extension blocks in .gif file */
  176.     short distest;
  177.     short floatflag;
  178.     short bailoutold;
  179.     long calctime;
  180.     BYTE trigndx[4];      /* which trig functions selected */
  181.     short finattract;
  182.     double initorbit[2];  /* init Mandelbrot orbit values */
  183.     short periodicity;      /* periodicity checking */
  184.             /* version 5 stuff, release 15 */
  185.     short pot16bit;      /* save 16 bit continuous potential info */
  186.     float faspectratio;   /* finalaspectratio, y/x */
  187.     short system;       /* 0 for dos, 1 for windows */
  188.     short release;      /* release number, with 2 decimals implied */
  189.     short flag3d;       /* stored only for now, for future use */
  190.     short transparent[2];
  191.     short ambient;
  192.     short haze;
  193.     short randomize;
  194.             /* version 6 stuff, release 15.x */
  195.     short rotate_lo;
  196.     short rotate_hi;
  197.     short distestwidth;
  198.             /* version 7 stuff, release 16 */
  199.     double dparm3;
  200.     double dparm4;
  201.             /* version 8 stuff, release 17 */
  202.     short fillcolor;
  203.             /* version 9 stuff, release 18 */
  204.     double mxmaxfp;
  205.     double mxminfp;
  206.     double mymaxfp;
  207.     double myminfp;
  208.     short zdots;
  209.     float originfp;
  210.     float depthfp;
  211.     float heightfp;
  212.     float widthfp;
  213.     float distfp;
  214.     float eyesfp;
  215.     short orbittype;
  216.     short juli3Dmode;
  217.     short maxfn;
  218.     short inversejulia;
  219.     double dparm5;
  220.     double dparm6;
  221.     double dparm7;
  222.     double dparm8;
  223.     double dparm9;
  224.     double dparm10;
  225.             /* version 10 stuff, release 19 */
  226.     long bailout;
  227.     short bailoutest;
  228.     long iterations;
  229.     short bf_math;
  230.     short bflength;
  231.     short yadjust;        /* yikes! we left this out ages ago! */
  232.     short old_demm_colors;
  233.     short future[42];      /* for stuff we haven't thought of yet */
  234. };
  235.  
  236. #define ITEMNAMELEN 18     /* max length of names in .frm/.l/.ifs/.fc */
  237. struct history_info    
  238. {
  239.     short fractal_type;
  240.     double xmin;
  241.     double xmax;
  242.     double ymin;
  243.     double ymax;
  244.     double creal;
  245.     double cimag;
  246.     double potential[3];
  247.     short rseed;
  248.     short rflag;
  249.     short biomorph;
  250.     short inside;
  251.     short logmap;
  252.     double invert[3];
  253.     short decomp;
  254.     short symmetry;
  255.     short init3d[16];
  256.     short previewfactor;
  257.     short xtrans;
  258.     short ytrans;
  259.     short red_crop_left;
  260.     short red_crop_right;
  261.     short blue_crop_left;
  262.     short blue_crop_right;
  263.     short red_bright;
  264.     short blue_bright;
  265.     short xadjust;
  266.     short eyeseparation;
  267.     short glassestype;
  268.     short outside;
  269.     double x3rd;      
  270.     double y3rd;
  271.     char stdcalcmode;
  272.     char three_pass;
  273.     char useinitorbit;      
  274.     short distest;
  275.     short bailoutold;
  276.     BYTE trigndx[4];      
  277.     short finattract;
  278.     double initorbit[2];  
  279.     short periodicity;      
  280.     short pot16bit;      
  281.     short release;
  282.     short save_release;
  283.     short flag3d; 
  284.     short transparent[2];
  285.     short ambient;
  286.     short haze;
  287.     short randomize;
  288.     short rotate_lo;
  289.     short rotate_hi;
  290.     short distestwidth;
  291.     double dparm3;
  292.     double dparm4;
  293.     short fillcolor;
  294.     double mxmaxfp;
  295.     double mxminfp;
  296.     double mymaxfp;
  297.     double myminfp;
  298.     short zdots;
  299.     float originfp;
  300.     float depthfp;
  301.     float heightfp;
  302.     float widthfp;
  303.     float distfp;
  304.     float eyesfp;
  305.     short orbittype;
  306.     short juli3Dmode;
  307.     char  maxfn;
  308.     short major_method;
  309.     short minor_method;
  310.     double dparm5;
  311.     double dparm6;
  312.     double dparm7;
  313.     double dparm8;
  314.     double dparm9;
  315.     double dparm10;
  316.     long bailout;
  317.     short bailoutest;
  318.     long iterations;
  319.     short bf_math;
  320.     short bflength;
  321.     short yadjust;
  322.     short old_demm_colors;
  323.     char filename[80];
  324.     char itemname[ITEMNAMELEN+1];
  325.     unsigned char dac[256][3];
  326. };
  327.  
  328. typedef struct history_info HISTORY;
  329.  
  330. #define MAXVIDEOMODES 300    /* maximum entries in fractint.cfg      */
  331. #ifndef XFRACT
  332. #define MAXVIDEOTABLE 40        /* size of the resident video modes table */
  333. #else
  334. #define MAXVIDEOTABLE 2         /* size of the resident video modes table */
  335. #endif
  336.  
  337. #define AUTOINVERT -123456.789
  338. #define ENDVID 22400   /* video table uses extra seg up to here */
  339.  
  340. #define N_ATTR 8            /* max number of attractors    */
  341.  
  342. extern    long     l_at_rad;    /* finite attractor radius  */
  343. extern    double     f_at_rad;    /* finite attractor radius  */
  344.  
  345. #define NUMIFS      64     /* number of ifs functions in ifs array */
  346. #define IFSPARM    7     /* number of ifs parameters */
  347. #define IFS3DPARM 13     /* number of ifs 3D parameters */
  348.  
  349. struct moreparams
  350. {
  351.    int      type;                        /* index in fractalname of the fractal */
  352.    char     *param[MAXPARAMS-4];    /* name of the parameters */
  353.    double   paramvalue[MAXPARAMS-4];     /* default parameter values */
  354. };
  355.  
  356. typedef struct moreparams far       MOREPARAMS;
  357.  
  358. struct fractalspecificstuff
  359. {
  360.    char  *name;             /* name of the fractal */
  361.                     /* (leading "*" supresses name display) */ 
  362.    char  *param[4];            /* name of the parameters */
  363.    double paramvalue[4];         /* default parameter values */
  364.    int     helptext;            /* helpdefs.h HT_xxxx, -1 for none */
  365.    int     helpformula;            /* helpdefs.h HF_xxxx, -1 for none */
  366.    unsigned flags;             /* constraints, bits defined below */
  367.    float xmin;                /* default XMIN corner */
  368.    float xmax;                /* default XMAX corner */
  369.    float ymin;                /* default YMIN corner */
  370.    float ymax;                /* default YMAX corner */
  371.    int     isinteger;            /* 1 if integerfractal, 0 otherwise */
  372.    int     tojulia;            /* mandel-to-julia switch */
  373.    int     tomandel;            /* julia-to-mandel switch */
  374.    int     tofloat;            /* integer-to-floating switch */
  375.    int     symmetry;            /* applicable symmetry logic
  376.                        0 = no symmetry
  377.                       -1 = y-axis symmetry (If No Params)
  378.                        1 = y-axis symmetry
  379.                       -2 = x-axis symmetry (No Parms)
  380.                        2 = x-axis symmetry
  381.                       -3 = y-axis AND x-axis (No Parms)
  382.                        3 = y-axis AND x-axis symmetry
  383.                       -4 = polar symmetry (No Parms)
  384.                        4 = polar symmetry
  385.                        5 = PI (sin/cos) symmetry
  386.                        6 = NEWTON (power) symmetry
  387.                                 */
  388. #ifdef XFRACT
  389.    int (*orbitcalc)();    /* function that calculates one orbit */
  390. #else
  391.    int (*orbitcalc)(void);    /* function that calculates one orbit */
  392. #endif
  393.    int (*per_pixel)(void);    /* once-per-pixel init */
  394.    int (*per_image)(void);    /* once-per-image setup */
  395.    int (*calctype)(void);    /* name of main fractal function */
  396.    int orbit_bailout;        /* usual bailout value for orbit calc */
  397. };
  398.  
  399. struct alternatemathstuff
  400. {
  401.    int type;            /* index in fractalname of the fractal */
  402.    int math;             /* kind of math used */
  403. #ifdef XFRACT
  404.    int (*orbitcalc)();    /* function that calculates one orbit */
  405. #else
  406.    int (*orbitcalc)(void);    /* function that calculates one orbit */
  407. #endif
  408.    int (*per_pixel)(void);    /* once-per-pixel init */
  409.    int (*per_image)(void);    /* once-per-image setup */
  410. };
  411.  
  412. typedef struct alternatemathstuff ALTERNATE;
  413.  
  414. /* defines for symmetry */
  415. #define  NOSYM        0
  416. #define  XAXIS_NOPARM  -1
  417. #define  XAXIS        1
  418. #define  YAXIS_NOPARM  -2
  419. #define  YAXIS        2
  420. #define  XYAXIS_NOPARM -3
  421. #define  XYAXIS     3
  422. #define  ORIGIN_NOPARM -4
  423. #define  ORIGIN     4
  424. #define  PI_SYM_NOPARM -5
  425. #define  PI_SYM     5
  426. #define  XAXIS_NOIMAG  -6
  427. #define  XAXIS_NOREAL    6
  428. #define  NOPLOT        99
  429. #define  SETUP_SYM    100
  430.  
  431. /* defines for inside/outside */
  432. #define ITER        -1
  433. #define REAL        -2
  434. #define IMAG        -3
  435. #define MULT        -4
  436. #define SUM         -5
  437. #define ATAN        -6
  438. #define ZMAG       -59
  439. #define BOF60      -60
  440. #define BOF61      -61
  441. #define EPSCROSS  -100
  442. #define STARTRAIL -101
  443. #define PERIOD    -102
  444.  
  445. /* defines for bailoutest */
  446. enum bailouts { Mod, Real, Imag, Or, And };
  447. enum Major  {breadth_first, depth_first, random_walk, random_run};
  448. enum Minor  {left_first, right_first};
  449.  
  450. /* bitmask defines for fractalspecific flags */
  451. #define  NOZOOM     1    /* zoombox not allowed at all          */
  452. #define  NOGUESS    2    /* solid guessing not allowed          */
  453. #define  NOTRACE    4    /* boundary tracing not allowed        */
  454. #define  NOROTATE    8    /* zoombox rotate/stretch not allowed  */
  455. #define  NORESUME      16    /* can't interrupt and resume          */
  456. #define  INFCALC       32    /* this type calculates forever        */
  457. #define  TRIG1           64    /* number of trig functions in formula */
  458. #define  TRIG2          128
  459. #define  TRIG3          192
  460. #define  TRIG4          256
  461. #define  WINFRAC      512    /* supported in WinFrac                */
  462. #define  PARMS3D     1024    /* uses 3d parameters                  */
  463. #define  OKJB        2048    /* works with Julibrot                 */
  464. #define  MORE        4096    /* more than 4 parms                   */
  465. #define  BAILTEST    8192    /* can use different bailout tests     */
  466. #define  BF_MATH    16384    /* supports arbitrary precision        */
  467. #define  LD_MATH    32768    /* supports long double                */
  468.  
  469. extern struct fractalspecificstuff far fractalspecific[];
  470. extern struct fractalspecificstuff far *curfractalspecific;
  471.  
  472. #define DEFAULTFRACTALTYPE    ".gif"
  473. #define ALTERNATEFRACTALTYPE    ".fra"
  474.  
  475. #ifndef _CMPLX_DEFINED
  476. #include "cmplx.h"
  477. #endif
  478.  
  479. #ifndef sqr
  480. #define sqr(x) ((x)*(x))
  481. #endif
  482.  
  483. #ifndef lsqr
  484. #define lsqr(x) (multiply((x),(x),bitshift))
  485. #endif
  486.  
  487. #define CMPLXmod(z)      (sqr((z).x)+sqr((z).y))
  488. #define CMPLXconj(z)    ((z).y =  -((z).y))
  489. #define LCMPLXmod(z)       (lsqr((z).x)+lsqr((z).y))
  490. #define LCMPLXconj(z)    ((z).y =  -((z).y))
  491.  
  492. typedef  _LCMPLX LCMPLX;
  493.  
  494. /* 3D stuff - formerly in 3d.h */
  495. #ifndef dot_product
  496. #define dot_product(v1,v2)  ((v1)[0]*(v2)[0]+(v1)[1]*(v2)[1]+(v1)[2]*(v2)[2])  /* TW 7-09-89 */
  497. #endif
  498.  
  499. #define    CMAX    4   /* maximum column (4 x 4 matrix) */
  500. #define    RMAX    4   /* maximum row     (4 x 4 matrix) */
  501. #define    DIM       3   /* number of dimensions */
  502.  
  503. typedef double MATRIX [RMAX] [CMAX];  /* matrix of doubles */
  504. typedef int   IMATRIX [RMAX] [CMAX];  /* matrix of ints    */
  505. typedef long  LMATRIX [RMAX] [CMAX];  /* matrix of longs   */
  506.  
  507. /* A MATRIX is used to describe a transformation from one coordinate
  508. system to another.  Multiple transformations may be concatenated by
  509. multiplying their transformation matrices. */
  510.  
  511. typedef double VECTOR [DIM];  /* vector of doubles */
  512. typedef int   IVECTOR [DIM];  /* vector of ints    */
  513. typedef long  LVECTOR [DIM];  /* vector of longs   */
  514.  
  515. /* A VECTOR is an array of three coordinates [x,y,z] representing magnitude
  516. and direction. A fourth dimension is assumed to always have the value 1, but
  517. is not in the data structure */
  518.  
  519.  
  520. #define PI 3.14159265358979323846
  521.  
  522. #define SPHERE      init3d[0]        /* sphere? 1 = yes, 0 = no  */
  523. #define ILLUMINE  (FILLTYPE>4)    /* illumination model        */
  524.  
  525. /* regular 3D */
  526. #define XROT      init3d[1]    /* rotate x-axis 60 degrees */
  527. #define YROT      init3d[2]    /* rotate y-axis 90 degrees */
  528. #define ZROT      init3d[3]    /* rotate x-axis  0 degrees */
  529. #define XSCALE      init3d[4]    /* scale x-axis, 90 percent */
  530. #define YSCALE      init3d[5]    /* scale y-axis, 90 percent */
  531.  
  532. /* sphere 3D */
  533. #define PHI1      init3d[1]    /* longitude start, 180     */
  534. #define PHI2      init3d[2]    /* longitude end ,   0        */
  535. #define THETA1      init3d[3]        /* latitude start,-90 degrees */
  536. #define THETA2      init3d[4]        /* latitude stop,  90 degrees */
  537. #define RADIUS      init3d[5]    /* should be user input */
  538.  
  539. /* common parameters */
  540. #define ROUGH      init3d[6]    /* scale z-axis, 30 percent */
  541. #define WATERLINE init3d[7]    /* water level            */
  542. #define FILLTYPE  init3d[8]    /* fill type            */
  543. #define ZVIEWER   init3d[9]    /* perspective view point   */
  544. #define XSHIFT      init3d[10]    /* x shift */
  545. #define YSHIFT      init3d[11]    /* y shift */
  546. #define XLIGHT      init3d[12]    /* x light vector coordinate */
  547. #define YLIGHT      init3d[13]    /* y light vector coordinate */
  548. #define ZLIGHT      init3d[14]    /* z light vector coordinate */
  549. #define LIGHTAVG  init3d[15]    /* number of points to average */
  550.  
  551. #ifndef TRUE
  552. #define TRUE 1
  553. #define FALSE 0
  554. #endif
  555.  
  556. /* Math definitions (normally in float.h) that are missing on some systems. */
  557. #ifndef FLT_MIN
  558. #define FLT_MIN 1.17549435e-38
  559. #endif
  560. #ifndef FLT_MAX
  561. #define FLT_MAX 3.40282347e+38
  562. #endif
  563. #ifndef DBL_EPSILON
  564. #define DBL_EPSILON 2.2204460492503131e-16
  565. #endif
  566.  
  567. /* gcc doesn't like the real DBL_MAX for some reason */
  568. #ifdef XFRACT
  569. #ifdef DBL_MAX
  570. #undef DBL_MAX
  571. #define DBL_MAX 1.79769313486231e+308
  572. #endif
  573. #endif
  574.  
  575. #ifndef XFRACT
  576. #define UPARR "\x18"
  577. #define DNARR "\x19"
  578. #define RTARR "\x1A"
  579. #define LTARR "\x1B"
  580. #else
  581. #define UPARR "K"
  582. #define DNARR "J"
  583. #define RTARR "L"
  584. #define LTARR "H"
  585. #endif
  586.  
  587. #define JIIM  0
  588. #define ORBIT 1
  589.  
  590. struct workliststuff    /* work list entry for std escape time engines */
  591. {
  592.     int xxstart;    /* screen window for this entry */
  593.     int xxstop;
  594.     int yystart;
  595.     int yystop;
  596.     int yybegin;    /* start row within window, for 2pass/ssg resume */
  597.     int sym;    /* if symmetry in window, prevents bad combines */
  598.     int pass;    /* for 2pass and solid guessing */
  599. };
  600.  
  601. typedef struct workliststuff        WORKLIST;
  602.  
  603.  
  604. #define MAXCALCWORK 12
  605.  
  606. struct coords {
  607.     int x,y;
  608.     };
  609.  
  610. struct dblcoords {
  611.     double x,y;
  612.     };
  613.  
  614. extern BYTE trigndx[];
  615. extern void (*ltrig0)(void), (*ltrig1)(void), (*ltrig2)(void), (*ltrig3)(void);
  616. extern void (*dtrig0)(void), (*dtrig1)(void), (*dtrig2)(void), (*dtrig3)(void);
  617.  
  618. struct trig_funct_lst
  619. {
  620.     char *name;
  621.     void (*lfunct)(void);
  622.     void (*dfunct)(void);
  623.     void (*mfunct)(void);
  624. } ;
  625. extern struct trig_funct_lst trigfn[];
  626.  
  627. /* function prototypes */
  628.  
  629. extern    void   (_fastcall *plot)(int, int, int);
  630.  
  631. /* for overlay return stack */
  632.  
  633. #define BIG 100000.0
  634.  
  635. #define CTL(x) ((x)&0x1f)
  636.  
  637. /* nonalpha tests if we have a control character */
  638. #define nonalpha(c) ((c)<32 || (c)>127)
  639.  
  640. /* keys */
  641. #define   INSERT     1082
  642. #define   DELETE     1083
  643. #define   PAGE_UP     1073
  644. #define   PAGE_DOWN     1081
  645. #define   CTL_HOME     1119
  646. #define   CTL_END     1117
  647. #define   LEFT_ARROW     1075
  648. #define   RIGHT_ARROW     1077
  649. #define   UP_ARROW     1072
  650. #define   DOWN_ARROW     1080
  651. #define   LEFT_ARROW_2     1115
  652. #define   RIGHT_ARROW_2  1116
  653. #define   UP_ARROW_2     1141
  654. #define   DOWN_ARROW_2     1145
  655. #define   HOME         1071
  656. #define   END         1079
  657. #define   ENTER      13
  658. #define   ENTER_2     1013
  659. #define   CTL_ENTER      10
  660. #define   CTL_ENTER_2    1010
  661. #define   CTL_PAGE_UP    1132
  662. #define   CTL_PAGE_DOWN  1118
  663. #define   CTL_MINUS      1142
  664. #define   CTL_PLUS       1144
  665. #define   CTL_INSERT     1146
  666. #define   CTL_DEL        1147
  667. #define   CTL_BACKSLASH  28
  668. #define   F1         1059
  669. #define   F2         1060
  670. #define   F3         1061
  671. #define   F4         1062
  672. #define   F5         1063
  673. #define   F6         1064
  674. #define   F7         1065
  675. #define   F8         1066
  676. #define   F9         1067
  677. #define   F10         1068
  678. #define   BACKSPACE     8
  679. #define   TAB            9
  680. #define   CTL_TAB        1148
  681. #define   ALT_TAB        1165
  682. #define   BACK_TAB     1015  /* shift tab */
  683. #define   ESC            27
  684. #define   SPACE          32
  685. #define   SF1            1084
  686. #define   SF2            1085
  687. #define   SF3            1086
  688. #define   SF4            1087
  689. #define   SF5            1088
  690. #define   SF6            1089
  691. #define   SF7            1090
  692. #define   SF8            1091
  693. #define   SF9            1092
  694. #define   SF10           1093
  695. /* text colors */
  696. #define BLACK       0
  697. #define BLUE       1
  698. #define GREEN       2
  699. #define CYAN       3
  700. #define RED       4
  701. #define MAGENTA    5
  702. #define BROWN       6 /* dirty yellow on cga */
  703. #define WHITE       7
  704. /* use values below this for foreground only, they don't work background */
  705. #define GRAY       8 /* don't use this much - is black on cga */
  706. #define L_BLUE       9
  707. #define L_GREEN   10
  708. #define L_CYAN      11
  709. #define L_RED      12
  710. #define L_MAGENTA 13
  711. #define YELLOW      14
  712. #define L_WHITE   15
  713. #define INVERSE 0x8000 /* when 640x200x2 text or mode 7, inverse */
  714. #define BRIGHT    0x4000 /* when mode 7, bright */
  715. /* and their use: */
  716. extern BYTE txtcolor[];
  717. #define C_TITLE       txtcolor[0]+BRIGHT
  718. #define C_TITLE_DEV      txtcolor[1]
  719. #define C_HELP_HDG      txtcolor[2]+BRIGHT
  720. #define C_HELP_BODY      txtcolor[3]
  721. #define C_HELP_INSTR      txtcolor[4]
  722. #define C_HELP_LINK      txtcolor[5]+BRIGHT
  723. #define C_HELP_CURLINK      txtcolor[6]+INVERSE
  724. #define C_PROMPT_BKGRD      txtcolor[7]
  725. #define C_PROMPT_TEXT      txtcolor[8]
  726. #define C_PROMPT_LO      txtcolor[9]
  727. #define C_PROMPT_MED      txtcolor[10]
  728. #ifndef XFRACT
  729. #define C_PROMPT_HI      txtcolor[11]+BRIGHT
  730. #else
  731. #define C_PROMPT_HI      txtcolor[11]
  732. #endif
  733. #define C_PROMPT_INPUT      txtcolor[12]+INVERSE
  734. #define C_PROMPT_CHOOSE   txtcolor[13]+INVERSE
  735. #define C_CHOICE_CURRENT  txtcolor[14]+INVERSE
  736. #define C_CHOICE_SP_INSTR txtcolor[15]
  737. #define C_CHOICE_SP_KEYIN txtcolor[16]+BRIGHT
  738. #define C_GENERAL_HI      txtcolor[17]+BRIGHT
  739. #define C_GENERAL_MED      txtcolor[18]
  740. #define C_GENERAL_LO      txtcolor[19]
  741. #define C_GENERAL_INPUT   txtcolor[20]+INVERSE
  742. #define C_DVID_BKGRD      txtcolor[21]
  743. #define C_DVID_HI      txtcolor[22]+BRIGHT
  744. #define C_DVID_LO      txtcolor[23]
  745. #define C_STOP_ERR      txtcolor[24]+BRIGHT
  746. #define C_STOP_INFO      txtcolor[25]+BRIGHT
  747. #define C_TITLE_LOW      txtcolor[26]
  748. #define C_AUTHDIV1      txtcolor[27]+INVERSE
  749. #define C_AUTHDIV2      txtcolor[28]+INVERSE
  750. #define C_PRIMARY      txtcolor[29]
  751. #define C_CONTRIB      txtcolor[30]
  752.  
  753. /* structure for xmmmoveextended parameter */
  754. struct XMM_Move
  755.   {
  756.     unsigned long   Length;
  757.     unsigned int    SourceHandle;
  758.     unsigned long   SourceOffset;
  759.     unsigned int    DestHandle;
  760.     unsigned long   DestOffset;
  761.   };
  762.  
  763. /* structure passed to fullscreen_prompts */
  764. struct fullscreenvalues
  765. {
  766.    int type;   /* 'd' for double, 'f' for float, 's' for string,   */
  767.            /* 'D' for integer in double, '*' for comment */
  768.            /* 'i' for integer, 'y' for yes=1 no=0              */
  769.            /* 0x100+n for string of length n           */
  770.            /* 'l' for one of a list of strings                 */
  771.            /* 'L' for long */
  772.    union
  773.    {
  774.       double dval;    /* when type 'd' or 'f'  */
  775.       int    ival;    /* when type is 'i'      */
  776.       long   Lval;    /* when type is 'L'      */
  777.       char   sval[16];    /* when type is 's'      */
  778.       char  far *sbuf;    /* when type is 0x100+n  */
  779.       struct {        /* when type is 'l'      */
  780.      int  val;    /*   selected choice     */
  781.      int  vlen;    /*   char len per choice */
  782.      char **list;    /*   list of values     */
  783.      int  llen;    /*   number of values     */
  784.       } ch;
  785.    } uval;
  786. };
  787.  
  788. #define   FILEATTR     0x37       /* File attributes; select all but volume labels */
  789. #define   HIDDEN     2
  790. #define   SYSTEM     4
  791. #define   SUBDIR     16
  792.  
  793. struct DIR_SEARCH        /* Allocate DTA and define structure */
  794. {
  795.      char path[21];        /* DOS path and filespec */
  796.      char attribute;        /* File attributes wanted */
  797.      int  ftime;        /* File creation time */
  798.      int  fdate;        /* File creation date */
  799.      long size;         /* File size in bytes */
  800.      char filename[13];     /* Filename and extension */
  801. };
  802.  
  803. extern struct DIR_SEARCH DTA;   /* Disk Transfer Area */
  804.  
  805. typedef struct palett
  806. {
  807.    BYTE red;
  808.    BYTE green;
  809.    BYTE blue;
  810. }
  811. Palettetype;
  812.  
  813. struct ext_blk_2 {
  814.    char got_data;
  815.    int length;
  816.    char far *resume_data;
  817.    };
  818.  
  819. struct ext_blk_3 {
  820.    char got_data;
  821.    char form_name[40];
  822.    };
  823.  
  824. struct ext_blk_4 {
  825.    char got_data;
  826.    int length;
  827.    int far *range_data;
  828.    };
  829.  
  830. struct ext_blk_5 {
  831.    char got_data;
  832.    int length;
  833.    char far *apm_data;
  834.    };
  835.  
  836. struct affine
  837. {
  838.    /* weird order so a,b,e and c,d,f are vectors */
  839.    double a;
  840.    double b;
  841.    double e;
  842.    double c;
  843.    double d;
  844.    double f;
  845. };
  846.  
  847. #define sign(x) (((x) < 0) ? -1 : ((x) != 0)  ? 1 : 0)
  848.  
  849. #if (_MSC_VER >= 700)
  850. typedef char __based(__segname("_CODE")) FCODE;
  851. #else
  852. typedef char far FCODE;
  853. #endif
  854.  
  855. #if (_MSC_VER >= 700)
  856. typedef BYTE __based(__segname("_CODE")) BFCODE;
  857. #else
  858. typedef BYTE far BFCODE;
  859. #endif
  860.  
  861. #if (_MSC_VER >= 700)
  862. typedef int __based(__segname("_CODE")) IFCODE;
  863. #else
  864. typedef int far IFCODE;
  865. #endif
  866.  
  867. #if (_MSC_VER >= 700)
  868. typedef unsigned int __based(__segname("_CODE")) UIFCODE;
  869. #else
  870. typedef unsigned int far UIFCODE;
  871. #endif
  872.  
  873. #if (_MSC_VER >= 700)
  874. typedef long __based(__segname("_CODE")) LFCODE;
  875. #else
  876. typedef long far LFCODE;
  877. #endif
  878.  
  879. #if (_MSC_VER >= 700)
  880. typedef double __based(__segname("_CODE")) DFCODE;
  881. #else
  882. typedef double far DFCODE;
  883. #endif
  884. #endif
  885.  
  886. #if _MSC_VER == 800 
  887. #ifndef FIXTAN_DEFINED
  888. /* !!!!! stupid MSVC tan(x) bug fix !!!!!!!!            */
  889. /* tan(x) can return -tan(x) if -pi/2 < x < pi/2       */
  890. /* if tan(x) has been called before outside this range. */
  891. double fixtan( double x );
  892. #define tan fixtan
  893. #define FIXTAN_DEFINED
  894. #endif
  895. #endif
  896.